package com.github.facadefs.sftp;

import java.util.StringTokenizer;

/**
 * SSH Utils.
 *
 * @author vacoor
 * @since 1.2.0
 */
abstract class Utils {
    private Utils() {
    }

    public static String[] parseUserAndGroup(final String longname) {
        if (null != longname) {
            final String[] ug = new String[2];
            // lrwxr-xr-x    1 root     wheel          11 Oct 11 16:09 etc
            final StringTokenizer tokenizer = new StringTokenizer(longname);
            for (int i = 0; i < 4 && tokenizer.hasMoreTokens(); i++) {
                final String token = tokenizer.nextToken();
                if (i == 2) {
                    ug[0] = token;
                } else if (i == 3) {
                    ug[1] = token;
                    return ug;
                }
            }
        }
        return new String[0];
    }
}
